<!doctype html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport"
          content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
</head>
<body>
        <div id="app">
            <h1>我是后台首页</h1>
            <h3>当前你的登录信息是: {{user.username}} === {{roles}}</h3>
            <a href="/logout" style="color: red">退出登录</a>
            <div style="margin-top: 50px">
                <a href="/user/get/1" style="color: green">根据id查询用户</a> &nbsp;&nbsp;&nbsp;&nbsp;
                <a href="/user/list" style="color: green">查询用户集合</a>&nbsp;&nbsp;&nbsp;&nbsp;
                <a href="/user/search" style="color: green">搜索用户列表</a>
            </div>
        </div>

<script src="/js/vue.js"></script>
<script src="/js/axios.min.js"></script>
<script>
    new Vue({
        el: "#app",
        data: {
            user: {},
            roles: {}
        },
        created() {
            this.loadUserInfo();
        },
        methods: {
            loadUserInfo() {
                axios.post("/getinfo").then(res => {
                    this.user = res.data;
                    this.roles = this.user.roles.map(res => res.title).join(",")
                })
            }
        }
    })
</script>

</body>
</html>